from tkinter import *
import socket
b=[]
#服务器端
root = Tk()  # 创建窗口对象的背景色
listb2 = Listbox(root)
while (str!="root.123"):
    s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    s.bind(('127.0.0.1',8001))
    s.listen()
    conn,addres=s.accept()
    data=conn.recv(1024)
    b.append(data.decode())
    print(data.decode())
    conn.sendall(("服务器已接收到内容"+str(data.decode())).encode())
    s.close()
for item in b:
    listb2.insert(0,item)
listb2.pack()
root.mainloop()
root.mainloop()
